package CollectionsDay01;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

public class CollectionDemo2 {
    public static void main(String[] args) {
        Collection c1 = new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add(".net");
        System.out.println("c1:"+c1);//[java, c++, .net]

        Collection c2 = new ArrayList();
        c2.add("android");
        c2.add("ios");
        c2.add("java");
        System.out.println("c2:"+c2);

        /**
         * boolean addAll(Collection c)
         * 将参数给定的集合中的所有元素添加到当前集合中,添加后当前集合发生改变则返回true
         */
        c1.addAll(c2);//将c2添加到c1中
        System.out.println("c1:"+c1);//[java, c++, .net, android, ios, java]
        System.out.println("c2:"+c2);//[android, ios, java]

        Collection c3 = new ArrayList();
        c3.add("c++");
        c3.add("android");
        c3.add("php");
        System.out.println("c3:"+c3);
        //boolean containsAll(Collection c)
//        判断当前集合中是否包含参数集合中的所有元素
        boolean contains = c1.contains(c3);
        System.out.println("是否包含所有:"+contains);
        c1.removeAll(c3);
        System.out.println("c1:"+c1);//[java, .net, ios, java]
        System.out.println("c3:"+c3);//[c++, android, php]
    }
}
